﻿using System;
using GDGeek;
using MrPP.iot.Guide;
using UnityEngine;

namespace MrPP.SerriedCabinet
{
    public class CellHightlight : CellStatus
    {


        [SerializeField]
        GuideTarget _target;
        [SerializeField]
        Renderer _renderer;

        [SerializeField]
        private BoxCollider _collider;
        [SerializeField]
        private CellBoard _board;
        void Start()
        {
            lowlight();
        }


        public void highlight(CabinetGroup.ItemData data)
        {
            Debug.LogError(JsonUtility.ToJson(data) + this.gameObject.longName());
            _collider.enabled = true;
            var color = _renderer.material.color;

            color.a = 1.0f;
            _renderer.material.color = color;
            _renderer.enabled = true;
            _board.show(data);
            if (GuideManager.Instance.target != _target)
            {
                GuideManager.Instance.target = _target;
            }
        }

        internal void reset()
        {
            //throw new NotImplementedException();
        }

        public void lowlight()
        {
            //Debug.LogError(JsonUtility.ToJson(data) + this.gameObject.longName());
            _board.hide();
           // Renderer renderer = this.gameObject.GetComponent<Renderer>();
            _collider.enabled = false;
            _renderer.enabled = false;

            if (GuideManager.Instance.target == _target)
            {
                GuideManager.Instance.target = null;
            }
        }

    }
}